<?php

class Gongzuo_typeModel extends Model {
	
	public function get_primary_key() {
		return $this->primary_key = 'id';
	}
	public function get_paisong_list(){
		
	}

	public function set($id, $data) {
	    if ($id) {
	        $this->update($data, 'id=' . $id);
	        return $id;
	    }
	    $this->insert($data);
	    if ($this->get_insert_id()) return $this->get_insert_id();
	    return false;
	}
	
	public function del($id) {
	    $this->delete('id=' . $id );
	}

    public function get_all(){
        $sql = 'select * from '.$this->prefix . 'gongzuo_type'.' where 1=1 order by id desc';
        return $this->db->query($sql)->result_array();
    }

    public function get_one($where){
        $sql = "select * from ".$this->prefix . "gongzuo_type where $where";
        return $this->db->query($sql)->row_array();
    }

	public function get_by_id($ids){
		if(!$ids){return false;}
		$sql = 'select * from '.$this->prefix . 'gongzuo_type'.' where 1=1 and id in ('.$ids.')';
		return $this->db->query($sql)->result_array();
	}

	 public function get_msg_by_name($name){
        $sql = "select * from ". $this->prefix . "gongzuo_type where  name='".$name."'";
	    return	$this->db->query($sql)->row_array(); 
	 }

    public function get_admin_list($where,$order,$limit,$ifcount=false){
        if($ifcount){
            $sql = "select count(id) as total from ".$this->prefix . "gongzuo_type
					where $where";
            $res = $this->db->query($sql)->row_array();
            return $res['total'];
        }
        $sql = "select * from ".$this->prefix . "gongzuo_type
		        where $where order by $order limit $limit";
        $res = $this->db->query($sql)->result_array();
        return $res;
    }

}